// const express = require('express');
// const app =express();

// app.post('/login',(req,res) => {
//     res.setHeader('Content-type','application/json;charset=utf-8');
//     res.end('登陆成功，欢迎回来~');
// });

// app.get('/home',(req,res) => {
//     res.setHeader('Content-type','application/json;charset=utf-8');
//     res.end('首页的轮播图/推荐数据列表~');
// })

// app.listen(9000,() => {
//     console.log('Express服务器启动成功~');
// });
/*-------------------------------------------------------------------------------------------------------------------------------*/

// const express = require('express');
// const app =express();

// app.post('/login',(req,res,next) => {
//     console.log = ('first middleware exec~');
//     req.age = 99;
//     next();
// })

// app.use((req,res,next) => {
//     console.log('second middleware exec~');
// });

// app.listen(9000,() => {
//     console.log('Express服务器启动成功~');
// });

/*-------------------------------------------------------------------------------------------------------------------------------*/

// const express = require('express');
// const app = express();

// app.use((req, res, next) => {
//  console.log('normal middleware 01');
//  next();
// });

// app.use((req, res, next) => {
//  console.log('normal middleware 02');
// });

// app.listen(9000, () => {
//  console.log('Express服务器启动成功~');
// });
/*-------------------------------------------------------------------------------------------------------------------------------*/

// const express = require('express');
// const app = express();

// app.use('/home', (req, res, next) => {
//  console.log('match /home middleware');
//  res.end('home data');
// });

// app.listen(9000, () => {
//  console.log('Express服务器启动成功~');
// });
// /*-------------------------------------------------------------------------------------------------------------------------------*/

// const express = require('express');
// const app = express();

// app.get('/home', (req, res, next) => {

//  console.log('match /home get method middleware');
//  res.end('home data');
// });

// app.post('/users', (req, res, next) => {
//  console.log('match /users post method middleware');
//  res.end('create user success');
// });

// app.listen(9000, () => {
//  console.log('Express服务器启动成功~');
// });
// /*-------------------------------------------------------------------------------------------------------------------------------*/

// const express = require('express');
// const app = express();

// app.get('/home',
//  (req, res, next) => {
//  console.log('match /home get middleware01');
//  next();
//  },
//  (req, res, next) => {
//  console.log('match /home get middleware02');
//  next();
//  },
//  (req, res, next) => {
//  console.log('match /home get middleware03');
//  next();
//  },
//  (req, res, next) => {
//  console.log('match /home get middleware04');
//  res.end('All middleware executed');
//  }
// );

// app.listen(9000, () => {
//  console.log('Express服务器启动成功~');
// });
// /*-------------------------------------------------------------------------------------------------------------------------------*/

// const express = require('express');
// const app = express();

// app.use((req, res, next) => {
//      console.log('normal middleware01');
//      next();
//     });
//     app.use((req, res, next) => {
//      console.log('normal middleware02');
//      next();
//     });
    
//     app.get('/home',
//      (req, res, next) => {
//      console.log('/home get middleware01');
//      next();
//      },
//      (req, res, next) => {
//      console.log('/home get middleware02');
//      res.end('GET /home response completed');
//      }
//     );
//     app.post('/login', (req, res, next) => {
//      console.log('/login post middleware');
//      res.end('POST /login response completed');
//     });

// app.use((req, res, next) => {
//     console.log('normal middleware03');
//     next();
//     });
//     app.use((req, res, next) => {
//     console.log('normal middleware04');
//     });
//     app.listen(9000, () => {
//     console.log('Express服务器启动成功~');
//     });
// /*-------------------------------------------------------------------------------------------------------------------------------*/     

// const express = require('express');
// const app = express();

// app.post('/login', (req, res, next) => {
 
//  let isLogin = false;
//  req.on('data', (data) => {
//  const dataString = data.toString();
//  const dataInfo = JSON.parse(dataString);
//  if (dataInfo.username === 'gkd' && dataInfo.password=== '123456') {
//     isLogin = true;
//  }
//  });
//  req.on('end', () => {
//  if (isLogin) {
//     res.end('登录成功, 欢迎回来~');
//  } else {
//     res.end('登录失败, 请检测账号和密码是否正确~');
//  }
//  });
// });

// app.post('/register', (req, res, next) => {
//    let isRegister = false;
//    req.on('data', (data) => {
//    const dataString = data.toString();
//    const dataInfo = JSON.parse(dataString);
//    isRegister = false;
//  });
// req.on('end', () => {
//    if (isRegister) {
//       res.end('注册成功, 开始你的旅程~');
//    } else {
//       res.end('注册失败, 您输⼊的⽤户名被注册~');
//    }
//  });
// });
// app.listen(9000, () => {
//  console.log('Express服务器启动成功~');
// });
// /*-------------------------------------------------------------------------------------------------------------------------------*/  

// const express = require('express');
// const app = express();

// app.use(express.json());
// app.post('/login', (req, res, next) => {
//    const { username, password } = req.body;
//    console.log(req.body);
//    if (username === 'gkd' && password === '123456') {
//    res.end('登录成功, 欢迎回来~');
//    } else {
//    res.end('登录失败, 请检测账号和密码是否正确~');
//    }
//   });

// app.post('/register', (req, res, next) => {
//    const { username } = req.body;
//    console.log(req.body);
//    const existingUsers = ['existinguser'];
//    if (existingUsers.includes(username)) {
//    res.end('注册失败, 您输⼊的⽤户名被注册~');
//    } else {
//    res.end('注册成功, 开始你的旅程~');
//    }
//   });
// app.listen(9000, () => {
//    console.log('Express服务器启动成功~');
//   });
// /*-------------------------------------------------------------------------------------------------------------------------------*/  
// const express = require('express');
// const app = express();

// app.use(express.json());
// app.use(express.urlencoded({ extended: true })); 

// app.post('/login', (req, res, next) => {
//  console.log(req.body);
//  res.end('登录成功, 欢迎回来~');
// });

// app.listen(9000, () => {
//  console.log('express服务器启动成功~');
// });
// /*-------------------------------------------------------------------------------------------------------------------------------*/ 
// const fs = require('fs');
// const express = require('express');
// const morgan = require('morgan');
// const app = express();

// const writeStream = fs.createWriteStream('./logs/bbb.log', { flags: 'a' });
// app.use(morgan('combined', { stream: writeStream }));

// app.post('/login', (req, res, next) => {
// res.end('登录成功, 欢迎回来~');
// });

// app.listen(9000, () => {
//  console.log('express服务器启动成功~');
// });
// /*-------------------------------------------------------------------------------------------------------------------------------*/ 
// const express = require('express');
// const multer = require('multer');

// const app = express();

// const upload = multer({ dest: './uploads' });

// app.post('/avatar', upload.single('avatar'), (req, res, next) => {
//  console.log(req.file); 
//  res.end('⽂件上传成功~');
// });

// app.listen(9000, () => {
//  console.log('express服务器启动成功~');
// });
// /*-------------------------------------------------------------------------------------------------------------------------------*/ 
// const express = require('express');
// const multer = require('multer');

// const app = express();

// const upload = multer({
//  storage: multer.diskStorage({
//  destination(req, file, callback) {

//  callback(null, './uploads');
//  },
//  filename(req, file, callback) {
//  callback(null, Date.now() + '_' + file.originalname);
//  },
//  }),
// });

// app.post('/avatar', upload.single('avatar'), (req, res, next) => {
//  console.log(req.file);
//  res.end('⽂件上传成功~');
// });
// app.post('/photos', upload.array('photos'), (req, res, next) => {
//  console.log(req.files); 
//  res.end('上传多张照⽚成功~');
// });
// app.listen(9000, () => {
//  console.log('express服务器启动成功~');
// });
// /*-------------------------------------------------------------------------------------------------------------------------------*/ 
// const express = require('express');
// const multer = require('multer');

// const app = express();

// app.use(express.json());
// app.use(express.urlencoded({ extended: true }));

// const formdata = multer();

// app.post('/login', formdata.any(), (req, res, next) => {
//  console.log(req.body); 
//  res.end('登录成功, 欢迎回来~');
// });
// // 启动服务器
// app.listen(9000, () => {
//  console.log('express服务器启动成功~');
// });
// /*-------------------------------------------------------------------------------------------------------------------------------*/ 
// const express = require('express');
// const app = express();

// app.get('/home/list', (req, res, next) => {
//  const queryInfo = req.query; 
//  console.log(queryInfo);
//  res.end('data list数据');
// });

// app.get('/users/:id', (req, res, next) => {
//  const id = req.params.id; 
//  res.end(`获取到${id}的数据~`);
// });

// app.listen(9000, () => {
//     console.log('express服务器启动成功~');
//    });
// /*-------------------------------------------------------------------------------------------------------------------------------*/ 
// const express = require('express');
// const app = express();

// app.post('/login', (req, res, next) => {
//     res.status(201);
//     res.json('创建⽤户成功~'); 
//    });
//    app.listen(9000, () => {
//     console.log('express服务器启动成功~');
//    });
// /*-------------------------------------------------------------------------------------------------------------------------------*/ 
// const express = require('express');
// const userRouter = require('./router/userRouter');

// const app = express();

// app.post('/login', (req, res, next) => {});
// app.get('/home', (req, res, next) => {});

// app.use('/users', userRouter);
// app.listen(9000, () => {
//  console.log('express服务器启动成功~');
// });
// /*-------------------------------------------------------------------------------------------------------------------------------*/   
const express = require('express');
const app = express();

app.use(express.static('./uploads'));
app.use(express.static('./build'));

app.post('/login', (req, res, next) => {});

app.listen(9000, () => {
 console.log('express服务器启动成功~');
}); 
// /*-------------------------------------------------------------------------------------------------------------------------------*/   